// 处理时间函，将事件处理为：xx天前
export function timeAgo(timestamp) {
  const now = Date.now();
  const secondsAgo = (now - timestamp) / 1000;
  const minutesAgo = secondsAgo / 60;
  const hoursAgo = minutesAgo / 60;
  const daysAgo = hoursAgo / 24;
  const monthsAgo = daysAgo / 30;

  if (secondsAgo < 60) {
    return '1分钟内';
  } else if (minutesAgo < 60) {
    return Math.floor(minutesAgo) + '分钟前';
  } else if (hoursAgo < 24) {
    return Math.floor(hoursAgo) + '小时前';
  } else if (daysAgo < 30) {
    return Math.floor(daysAgo) + '天前';
  } else if (monthsAgo < 3) {
    return Math.floor(monthsAgo) + '月前';
  } else {
    return null;
  }
}